<?php 
  error_reporting(E_ALL^E_NOTICE); //取消警告显示
  header('Content-type:application/json');
  date_default_timezone_set("Asia/Shanghai");
  include $_SERVER['DOCUMENT_ROOT']."/common/fun.php";
  include "../conn.php";//https

  $userid = get_post_para('userid',true);
  $deviceid = get_post_para('deviceid',true);
  $moduleid = get_post_para('moduleid',true);
  $timer = get_post_para('timer',true);
  if (!$con)
  {
    $myArray["resault"]='fail';
    $myArray["error"]='数据库读取错误！';
    $json = json_encode($myArray,JSON_UNESCAPED_UNICODE);
    echo $json;
  }
  else
  {
    $sql_update = "UPDATE device_switch set timer='$timer' where userid='$userid' and deviceid='$deviceid' and moduleid='$moduleid'";
    $res_update = mysqli_query($con,$sql_update);
    if ($res_update)   
    {
      $myArray["resault"] = 'success';
    } 
    else{
      $myArray["msg"]=mysqli_error($con);
      $myArray["resault"] = 'fail';
    } 
  }
  $json = json_encode($myArray,JSON_UNESCAPED_UNICODE);
  echo $json;
?>
